import request from '@/router/axios';

export const statusData = [
  {
    label: '未提交',
    value: 1
  },
  {
    label: '审批中',
    value: 2
  },
  {
    label: '已通过',
    value: 3
  },
  {
    label: '已驳回',
    value: 4
  }
]

// 资产编号二维码-台账
export const getPringInfo = (id) => {
  return request({
    url: '/api/hg-equipment/account/print',
    method: 'post',
    params: {
      id
    },
    responseType:'blob',
  })
}

export const pullTree = () => {
  return request({
    url: '/api/hg-public/relation/pullTree',
    method: 'get'
  })
}

// 获取指定部门下维修人员
export const getRepairPerson = (deptId) => {
  return request({
    url: '/api/hg-equipment/repair/person/pullList',
    method: 'get',
    params: {
      deptId
    }
  })
}
// 获取所有维修人员
export const getRepairUsers = () => {
  return request({
    url: '/api/hg-equipment/repair/person/repairUsers',
    method: 'get'
  })
}

// 获取部门列表
export const getAllDept = () => {
  return request({
    url: '/api/blade-system/dept/getAllDepts',
    method: 'get',
  })
}

// 维修任务中获取备件
export const getSpare = (oriEptCode) => {
  return request({
    url: '/api/hg-public/relation/getSpare',
    method: 'get',
    params: {
      oriEptCode
    }
  })
}

// 维修任务中获取物料
export const getMaterial = () => {
  return request({
    url: '/api/hg-public/relation/getMaterial',
    method: 'get',
  })
}

// 删除备件/物料
export const deleteUses = (id) => {
  return request({
    url: '/api/hg-equipment/repair/result/delete/taskUse',
    method: 'post',
    params: {
      id
    }
  })
}

// 人资获取部门人员对应关系树
export const getAllDeptPeople = () => {
  return request({
    url: '/api/blade-human/human-resources/personnel/personnelinforeport/findLis',
    method: 'get'
  })
}

export const addNum = (num1, num2) => {
  let sq1,sq2,m;
  try {
    sq1 = num1.toString().split(".")[1].length;
  }
  catch (e) {
    sq1 = 0;
  }
  try {
    sq2 = num2.toString().split(".")[1].length;
  }
  catch (e) {
    sq2 = 0;
  }
  m = Math.pow(10,Math.max(sq1, sq2));
  return (num1 * m + num2 * m) / m;
}
export const accMul = (arg1,arg2) => {
  let m=0
  let s1=arg1.toString()
  let s2=arg2.toString()
  try{
    m += s1.split('.')[1].length
  }catch(e){
    m=m*1
  }
  try{
    m += s2.split('.')[1].length
  }catch(e){
    m=m*1
  }
  return Number(s1.replace('.', '')) * Number(s2.replace('.', '')) / Math.pow(10,m)
}
export const reduceNum = (num1, num2) => {
  let sq1,sq2,m;
  try {
    sq1 = num1.toString().split(".")[1].length;
  }
  catch (e) {
    sq1 = 0;
  }
  try {
    sq2 = num2.toString().split(".")[1].length;
  }
  catch (e) {
    sq2 = 0;
  }
  m = Math.pow(10,Math.max(sq1, sq2));
  return (num1 * m - num2 * m) / m;
}